// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose: declaration of CPEValueElement.
//   $Id$
#pragma once


#pragma once

#include "ElementWithXBL.h"
#include "CComBSTRPtrList.h"


#ifndef __PEVALUEELEMENT_H_
#define __PEVALUEELEMENT_H_ 1


#define CPEVALUEELEMENT_EVENTS_LENGTH 9

class CPEValueElement :  
	public CElementWithXBL
{
public:
	CPEValueElement(void);
	~CPEValueElement(void);

	HRESULT onfp_valuechanged(BSTR bsVal);
	HRESULT onfp_valuechanging(BSTR bsVal);
	HRESULT onfp_focusin();
	HRESULT onfp_focusout();
	HRESULT onfp_activate();
	HRESULT onfp_hint();
	HRESULT onfp_next();
	HRESULT onfp_previous();
	HRESULT onfp_uiready();

	HRESULT GetParentElement(IHTMLElement ** pEl);

	virtual HRESULT getXML(IXMLDOMNode ** ppXML);
	//Do not set the class properties for pe--value.
	virtual HRESULT required(BOOL bRequired){return S_FALSE;};
	virtual HRESULT readonly(BOOL bRequired){return S_FALSE;};
	virtual HRESULT enable(BOOL bRequired){return S_FALSE;};
	virtual HRESULT valid(BOOL bRequired){return S_FALSE;};
	virtual HRESULT SetClassProperty(bool bEnabled, bool bReadOnly, bool bValid, bool bRequired){return S_FALSE;};
protected:

	virtual HRESULT handleEvent(CComBSTR& sEventName, IHTMLEventObj2 * pEventObject,VARIANT * pvarResult);
	virtual HRESULT DocumentReady();

	virtual HRESULT InitBehaviour();
	//branding should only occur on the real element, not the value PsuedoElement.
	virtual HRESULT InsertBranding(void){return S_FALSE;};
	virtual HRESULT GetLocallySpecifiedBindingId(CComBSTR & bsId);
private:

	static const CComBSTR * const sm_asEventNames[CPEVALUEELEMENT_EVENTS_LENGTH];
	long m_alEventCookies[CPEVALUEELEMENT_EVENTS_LENGTH];

	CComBSTRPtrList m_lstParentEvents;

	
	HRESULT attachEvents(IHTMLDocument3 * pDoc3 = 0);
	HRESULT attachParentEvents();
	
	void populateParentEvents();
	void populateEvents();
	
	HRESULT detachParentEvents();
	virtual HRESULT detachEvents();
};


#endif // __PEVALUEELEMENT_H_
